// Noise to play when we touch the jail bar
datablock AudioProfile(JailZap)
{
	filename = "~/data/shapes/jail/zap.wav";
	description = AudioClose3d;
	preload = true;
};

// Jail bar object
datablock ItemData(JailBar)
{
   category            = "Jail";
   shapeFile           = "~/data/shapes/jail/laserbar.dts";
   directDamage        = 1;
   radiusDamage        = 0;
   damageRadius        = 0.0;
   areaImpulse         = 2000;

   armingDelay         = 0;
   lifetime            = 5000;
   fadeDelay           = 5000;
   bounceElasticity    = 0;
   bounceFriction      = 0;
   gravityMod          = 0.80;
   mass                = 100;
   density             = 100;
   
   hasLight            = true;
   lightRadius         = 4;
   lightColor          = "1 0.0 0.0 1.0";
   lightType           = "ConstantLight";
};

// Cause damage to occur when something touches the laser bar
function JailBar::onCollision(%this,%obj,%col,%fade,%pos,%normal)
{
	if (%col.getType() & $TypeMasks::ShapeBaseObjectType)
	  %col.damage(%obj,%pos,%this.directDamage,"LaserBar");
 
	// This was fine when we only had one cell.  With multiple cells, we'd have to do some fairly complex vector computations
	// to determine which way to apply the impulse.  Instead, we'll just use an invisible wall to keep them from going past.
	//%impulseVector = VectorScale("3 0 0", %this.mass * 10);
	//LocalClientConnection.player.applyImpulse(LocalClientConnection.player.getWorldBoxCenter(), %impulseVector);

	serverPlay3D(JailZap, %obj.getTransform());
}



// This will let us create an invisible wall which will actually block the player from passing through the jail cell
datablock StaticShapeData(JailBlock)
{
	category = "Jail";
	shapeFile = "~/data/shapes/cardswipe/cardswipe.dts";
};

function JailBlock::OnAdd(%this, %obj)
{
	%obj.setCloaked(true);
}
